package com.plian.system.service.qg.subsidiary.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.Tools.CollectionUtil;
import com.plian.system.entity.qg.subsidiary.MixedOwnershipStructure;
import com.plian.system.mapper.qg.subsidiary.MixedOwnershipStructureMapper;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.service.qg.subsidiary.IMixedOwnershipStructureService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 混改后企业股权结构 服务实现类
 *
 * @author jianglei
 * @since 2019-10-23
 */
@Slf4j
@Service
@AllArgsConstructor
public class MixedOwnershipStructureServiceImpl extends BaseServiceImpl<MixedOwnershipStructureMapper, MixedOwnershipStructure> implements IMixedOwnershipStructureService {

	@Override
	public Boolean deleteLogicByMixedReformId(List<Long> ids) {
		LambdaQueryWrapper<MixedOwnershipStructure> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.in(MixedOwnershipStructure::getMixedReformId, ids);
		List<MixedOwnershipStructure> mixedOwnershipStructures = list(queryWrapper);
		if (CollectionUtil.isNotEmpty(mixedOwnershipStructures)){
			return deleteLogic(mixedOwnershipStructures.stream().map(MixedOwnershipStructure::getId).collect(Collectors.toList()));
		}
		return true;
	}
}
